﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
 using System.ComponentModel;
 using System.Runtime.Serialization;
 using System.Collections.ObjectModel;

namespace Qplus.UI
{
    public partial class TestPage : PhoneApplicationPage
    {
        ContentCollection mySource;
        int count = 0;
        public TestPage()
        {
            InitializeComponent();
            mySource = new ContentCollection();
            listBox1.ItemsSource = mySource;
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Content content = new Content();
            //content.Img = "http://pic.cnblogs.com/face/u97911.jpg";
            //content.Time = DateTime.Now.ToString();
            //content.Count = count.ToString();
            FriendControl newfriend = new FriendControl();
            content.Friend = newfriend;
            count++;
            mySource.Add(content);
        }
        public class Content
        {
            private string time;
            private string count;
            private string img;
            private FriendControl friend;

            public string Time
            {
                get { return time; }
                set
                {
                    if (time != value)
                        time = value;
                    NotifyPropertyChanged("Time");
                }
            }

            public string Count
            {
                get { return count; }
                set
                {
                    if (count != value)
                        count = value;
                    NotifyPropertyChanged("Count");
                }
            }

            public string Img
            {
                get { return img; }
                set
                {
                    if (img != value)
                        img = value;
                    NotifyPropertyChanged("Img");
                }
            }

            public FriendControl Friend
            {
                get { return friend; }
                set
                {
                    friend = value;
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;
            private void NotifyPropertyChanged(string info)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(info));
                }
            }
        }
        public class ContentCollection : ObservableCollection<Content>
        {
            public ContentCollection()
                : base()
            {
            }
        }
    }
}